Repository navigation
fix(studio): keep a sealed drag's waiting outline until the frame draws its replay - #8588
Conversation
terencecho
left a comment
There was a problem hiding this comment.
P2 — Wait for the frame that receives the replay. packages/studio/src/components/editor/previewGestureStarts.ts:253 passes the iframe captured at pointer-down to previewDraftsSent. If the save replaces that iframe, askShownFrame reads the replacement and the replay draws into its queue. The old queue can already be empty, so the outline clears before the shown frame draws. I reproduced this by swapping the opaque iframe while the press waited and holding the replacement’s draw. The waiting attribute was already gone. Wait on the frame used by the replay and cover the replacement in the regression test.
Both existing focused suites passed, 54 tests. The replacement-frame probe failed at this head.
— tai (automated review)
Edit accuracy: accurate 271 (base branch 271), smooth 62 of thoseThe gate passes. Quarantined, measured but not gated (0) |
|
Fixed in 9f82018: the outline now waits on the frame shown when the replay runs, so a frame swapped in during the wait holds it until that frame has drawn. Red row: "keeps the waiting outline until the frame the change swapped in has drawn the replay" ( |
terencecho
left a comment
There was a problem hiding this comment.
P2 — Give each replay ownership of its outline. The single frame-swap case is fixed. At packages/studio/src/components/editor/previewGestureStarts.ts:243–256, an older replay’s completion still clears the shared outline whenever waitingPressRef.current is null. It is also null once a newer replay starts waiting for its own frame to draw. I reproduced this with two replays on different iframe instances. Resolving the older frame’s wait first removed the newer outline while its draw was still pending. Guard cleanup with the press or replay identity that owns the outline, and cover the out-of-order completions.
All 55 existing focused tests passed. The two-replay probe failed at this head.
— tai (automated review)
|
Fixed in aacb2e4, by shape rather than by case: the outline is now one state (idle, waiting on the save, waiting on a replay's draw in a frame). Only the current replay's confirmation can clear it, and a frame swapped in moves the wait to that frame. The table is in the description. Rows: "keeps a newer replay's outline when an older replay's frame answers first" and "waits on the frame swapped in after the replay, not the one it drew in" fail at 9f82018; two more pin a press arriving during the draw wait and the overlay leaving. |
terencecho
left a comment
There was a problem hiding this comment.
P2 — Keep replay ownership across overlay renders. packages/studio/src/components/editor/previewGestureStarts.ts:59 stores drawWait in one handler instance. DomEditOverlay.tsx:280 recreates the handlers on render. A newer press can invalidate the wait in its new instance while the old callback still owns the wait in its old instance. I updated the existing second-press test to recreate the handlers with the same refs, as the overlay does. The old frame’s reply removed the outline while the newer press was still waiting. Store the replay identity in overlay-lifetime state shared by the handlers and cleanup, and test a re-render between presses.
All 59 existing focused tests passed. The re-render variant failed at this head.
— tai (automated review)
|
Fixed in af800ee: the outline's state moved out of the handlers into one owner per overlay mount ( |
terencecho
left a comment
There was a problem hiding this comment.
The outline owner now survives handler recreation because both handler sets share the mount’s ref. I verified that the re-render regression fails with the previous implementation and passes at this head. All 60 focused tests passed. I did not rerun the browser bench.
— tai (automated review)
terencecho
left a comment
There was a problem hiding this comment.
The refactor preserves the outline transitions. A queued press keeps its outline, a sealed replay waits for its frame, and a replay without a frame clears the outline. The mount still owns the state across handler recreation. All 60 focused tests passed. I did not rerun the browser bench.
— tai (automated review)
What
On a sealed preview, a drag pressed while the previous edit was still saving no longer shows the layer back at the drag's start for one frame when the save lands. In the edit bench's back-to-back drag case (resize, move, resize, move on one layer), the layer jumped 312 px on the second and fourth drags; now it follows the pointer the same as unsealed.
Why
A canvas press waits while an edit is saving, in both modes, and replays its moves once the save has landed. Unsealed, the replay redraws the layer in the same task that ends the wait, so no frame paints between them. Sealed, the replay's draw reaches the frame one round trip later. Meanwhile the waiting outline was already gone and the save's own patch had put the layer at the drag's start. That frame, between the outline going and the replay arriving, was the jump.
Related work
Follows #8563, which made the sealed save's patch draw in its own task; that left this frame.
How
The waiting outline on a sealed preview is one small state machine with one owner,
pressOutline.ts. There is one outline per overlay mount, keyed by the mount'swaitingPressRefand created on first use, so it outlives the handlers the overlay recreates on every render. The handlers inpreviewGestureStarts.tshold no outline state; they only send it events (waitOnSave,replayEnded,idle). Each replay's wait is its id, and only the current one may clear the outline.endWaitingPress)Unsealed presses never enter the draw wait: their replay draws in the same task, so the outline goes when the wait ends, as before. No message to the runtime changes, so an older runtime behaves the same.
No visible change
The interface doesn't change: the layer just no longer jumps when a sealed drag starts during a save.
Test plan
fails without the fix:
packages/studio/src/components/editor/previewOverlayRects.test.ts: "keeps the waiting outline until the frame has drawn the replayed drag", "keeps the waiting outline until the frame the change swapped in has drawn the replay", "keeps a newer replay's outline when an older replay's frame answers first", "waits on the frame swapped in after the replay, not the one it drew in", "keeps a press's outline made after a re-render when the replay before it answers"."keeps a press's outline that comes while the replay before it waits on its frame" and "drops the outline at once when the overlay leaves, and a late answer changes nothing" pin the other two stale-confirmation cases in the table.
gestureHoldsPreviewReload.test.tsxpass three runs in a row on Linux (60 tests). Studio'ssrc/components/editor(182 files, 2,197 tests) passes, and Studio typechecks clean.seqheldtwiceroot and nested, two runs each, sealed and unsealed, on main and with the fix. The worst box jump per drag on main sealed was up to 312.4 px on drags 2 and 4, and the teleport check failed 4 of 4. With the fix: at most 0.1 px on every drag in both modes, and the teleport check passes 4 of 4, the same as unsealed. Thesmoothcheck fails in every run, main unsealed included, so it isn't this change. Rerun with the state machine (aacb2e4), sealed and unsealed: element jumps 0 on every drag and teleport passes in every run.